
import { Body, Controller, Get, Put } from '@nestjs/common';
import { BaseController } from '../../base/base.controller';
import { DbService } from '../../db/db.service';
import { PlatformConfig } from '@app/db/common/entities/PlatformConfig';

@Controller('platform/config')
export class PlatformController extends BaseController{
    constructor(
        private readonly db:DbService
    ){
        super()
    }

    @Get()
    async getConfig() {
        const data = await this.db.platformConfig.queryConfig()
        return this.successRes(data)
    }

    @Get('staticUrl')
    async staticUrl() {
        const data = await this.db.platformConfig.queryConfig(['staticUrl'])
        return this.successRes(data.staticUrl)
    }

    @Put('update')
    async updateData(@Body() dto:PlatformConfig) {
        this.db.platformConfig.updateConfig(dto)
        return this.successRes()
    }
}
